<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>采用事件绑定</title>
</head>

<body>
    <ul id="list">
        <li>zzz</li>
        <p>sddd</p>
        <li>13</li>
        <li>哈哈哈</li>
    </ul>

    <script>
        var list = document.querySelectorAll('li')

        function clickFn(e) {
            if (e.target.nodeName.toLowerCase() == 'li') {
                console.log('item', e.target.innerHTML);
            }
        }
        // 循环遍历
        for (let item of list) {
            item.onclick = clickFn
        }
        // 事件委托
        var list = document.getElementById('list')
        list.addEventListener('click', clickFn, true)


        // 事件委托值操作一个元素，执行效率高于循环遍历绑定事件
    </script>
</body>

</html>